package de.wolvan.tools;

import java.io.*;
import java.util.Properties;

public class data {
	
	public static String pFile = "XIMVars.properties";
	
	public static boolean setProperty(String name, String data){
		
		//System.out.println("Saving " + name + " with value " + data + " in file " + pFile);
		Properties p = new Properties();
		p.setProperty(name, data);
		try {
			p.store(new FileWriter(pFile), "");
			//System.out.println("Successfully stored value!");
			return true;
		} catch (IOException e) {
			//System.out.println("Unable to store value! IO Exception!");
			e.printStackTrace();
			return false;
		}
		
	}
	
	public static String getProperty(String name) {
		
		//System.out.println("Getting property " + name + " from " + pFile);
		String prop = "";
		Properties p = new Properties();
		try {
			p.load(new FileReader(pFile));
			prop = p.getProperty(name);
			//System.out.println("Returning property " + name + " with value " + prop);
		} catch (FileNotFoundException e) {
			//System.out.println("Unable to get property! Properties file not found!");
			e.printStackTrace();
		} catch (IOException e) {
			//System.out.println("Unable to get property! IO Exception!");
			e.printStackTrace();
		}
		
		return prop;
		
		
	}
	
}
